package com.hyk.commonLib.common.drawable;

import android.animation.ObjectAnimator;
import android.graphics.drawable.Animatable;

import java.io.Serializable;


/**
 * Created by 贺玉琨 on 2019/3/7
 */

public abstract class BaseAnimDrawable extends BaseDrawable implements Animatable, Serializable {
    protected int currentProgress = 0;
    protected ObjectAnimator animator;

    protected BaseAnimDrawable() {
        super();
        animator = initAnimator();
    }

    @Override
    public void start() {
        if (animator.isRunning()) return;
        animator.start();
    }

    @Override
    public void stop() {
        animator.cancel();
    }

    @Override
    public boolean isRunning() {
        return animator.isRunning();
    }

    public void clearCache() {
    }

    protected abstract ObjectAnimator initAnimator();
}
